<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="templateadmin1.xhtml">
        <ui:define name="content">
            <script type="text/javascript">

           
     function testResults (form) {
      var TestVar = form.elements["tour:txtPrice"];
      var tax_id = parseFloat(TestVar.value);
      if(isNaN(tax_id)){
          alert ("You have input float");
          TestVar.value =0;
          return false;
      }
      return true;
  
      }

       function testDates (form) {
      var Test1 = form.elements["tour:txtfdate"];
      var now=new Date();
      var test2=form.elements["tour:txtedate"];
      var d1 = new Date(Test1.value);
      var d2=new Date(test2.value);
      if(d1>d2){
          alert ("your select Date not valid");
          return false;
      }
      return true;

      }
    



    
            </script>
            <center>
                <table border="0" id="detail-table">
                    <h1>New Package Tour</h1>
                    <h:form id="tour" >
                            <tr>
                                <td>Tour Name</td>
                                <td><h:inputText value="#{tourBean.ptour.packageTourName}" styleClass="inp-form" id="txtTourName" requiredMessage="please input name" required="true"></h:inputText></td>
                                <td><h:message for="txtTourName" style="color: red" ></h:message></td>
                            </tr>
                            <tr>
                                <td>Package Type</td>
                                <td> <h:selectOneMenu value="#{tourBean.packageID}" styleClass="styledselect_form_hungtl" >
                                        <f:selectItems value="#{tourBean.lpackagetype}" var="package" itemLabel="#{package.packageTypeName}" itemValue="#{package.packageTypeID}"></f:selectItems>
                                    </h:selectOneMenu></td>
                            </tr>
                            <tr>
                                <td>Location</td>
                                <td> <h:selectOneMenu value="#{tourBean.locationID}"  styleClass="styledselect_form_hungtl" onchange="submit()" valueChangeListener="#{tourBean.placeChangeByID}">
                                        <f:selectItems value="#{tourBean.llocation}" var="loc" itemLabel="#{loc.locationName}" itemValue="#{loc.locationID}"></f:selectItems>
                                    </h:selectOneMenu></td>
                            </tr>
                            <tr>
                                <td>Place</td>
                                <td> <h:selectOneMenu value="#{tourBean.placeID}"  styleClass="styledselect_form_hungtl" onchange="submit()" valueChangeListener="#{tourBean.hotelChangeByID}">
                                        <f:selectItems value="#{tourBean.lplaces}" var="place" itemLabel="#{place.placeName}" itemValue="#{place.placeID}"></f:selectItems>
                                    </h:selectOneMenu> </td>
                            </tr>
                            <tr>
                                <td>Hotel</td>
                                <td> <h:selectOneMenu value="#{tourBean.hotelID}" styleClass="styledselect_form_hungtl" >
                                        <f:selectItems value="#{tourBean.lhotel}" var="hotel" itemLabel="#{hotel.hotelName}" itemValue="#{hotel.hotelID}"></f:selectItems>
                                    </h:selectOneMenu></td>
                            </tr>
                            <tr>
                                <td>Price</td>
                                <td><h:inputText value="#{tourBean.ptour.price}"  styleClass="inp-form" onblur="testResults(this.form);" id="txtPrice" required="true"></h:inputText></td>
                            </tr>
                            <tr>
                                <td>Travel</td>
                                <td><h:selectOneMenu value="#{tourBean.ptour.travel}" styleClass="styledselect_form_hungtl">
                                        <f:selectItem itemLabel="Plane" itemValue="Plane"></f:selectItem>
                                        <f:selectItem itemLabel="car" itemValue="car"></f:selectItem>
                                        <f:selectItem itemLabel="train" itemValue="train"></f:selectItem>
                                    </h:selectOneMenu></td>
                            </tr>
                            <tr>
                                <td>Status</td>
                                <td><h:selectOneMenu value="#{tourBean.ptour.available}" styleClass="styledselect_form_hungtl">

                                        <f:selectItem itemLabel="active" itemValue="True"></f:selectItem>
                                        <f:selectItem itemLabel="wait" itemValue="False"></f:selectItem>
                                    </h:selectOneMenu></td>
                            </tr>
                            <tr>
                                <td>Description</td>
                                <td> <h:inputTextarea   styleClass="form-textarea2" value="#{tourBean.ptour.description}" id="txtdes" required="true" requiredMessage="input description"></h:inputTextarea></td>
                                <td><h:message for="txtdes" style="color: red"></h:message></td>
                            </tr>
                            <tr>
                                <td>From Date</td>
                                <td> <p:calendar   pattern="MM/dd/yyyy"  mindate="#{tourBean.datenow}"  value="#{tourBean.fdate}" id="txtfdate"></p:calendar></td>
                            </tr>
                            <tr>
                                <td>To Date</td>
                                <td> <p:calendar  pattern="MM/dd/yyyy"   mindate="#{tourBean.fdate}"  value="#{tourBean.edate}"  id="txtedate" required="true" ></p:calendar></td>
                                
                            </tr>

                            <tr>
                                <td>Image</td>
                                <td><p:fileUpload widgetVar="uploader2" fileUploadListener="#{uploadbean.fileUpload}" id="UploadPath" auto="true" ></p:fileUpload></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td><h:commandButton value="Create" action="#{tourBean.createTour}" styleClass="form-submit"></h:commandButton></td>
                            </tr>
                    </h:form>
                </table>
            </center>

        </ui:define>

    </ui:composition>

</html>



